﻿using System;
using System.Data;
using BusinessLayer;


namespace RemoteObject
{
    public class RemoteObject : MarshalByRefObject
    {
        public DataTable GetFlights(DateTime date, string sector)
        {
            DataTable dt = new DataTable();

            try
            {
                using (BL bLayer = new BL())
                {
                    dt = bLayer.GetFlights(date, sector);
                }
            }
            catch (Exception ex)
            {
                throw ex;
            }

            return dt;
        }

        public DataTable GetFlightsBySector(string sector)
        {
            DataTable dt = new DataTable();

            try
            {
                using (BL bLayer = new BL())
                {
                    dt = bLayer.GetFlights(sector);
                }
            }
            catch (Exception ex)
            {
                throw ex;
            }

            return dt;
        }

        public int GetWaitListCount(string flightNo)
        {
            int waitListCount = 0;

            try
            {
                using (BL bLayer = new BL())
                {
                    waitListCount = bLayer.GetWaitListCount(flightNo);
                }
            }
            catch (Exception ex)
            {
                throw ex;
            }

            return waitListCount;
        }

        public bool Reserve(int pnr, string flightNo, string fName, string lName, int age, char gender, char seatClass, string seatPref, string mealPref, string ssr, string status, DateTime date)
        {
            try
            {
                using (BL bLayer = new BL())
                {
                    return bLayer.Reserve(pnr, flightNo, fName, lName, age, gender, seatClass, seatPref, mealPref, ssr, date);
                }
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }

        public DataTable GetPassenger(int pnr)
        {
            DataTable dt = new DataTable();
            try
            {
                using (BL bLayer = new BL())
                {
                    dt = bLayer.GetPassenger(pnr);
                }
            }
            catch (Exception ex)
            {
                throw ex;
            }

            return dt;
        }

        public DataTable GetPassengers()
        {
            DataTable dt = new DataTable();
            try
            {
                using (BL bLayer = new BL())
                {
                    dt = bLayer.GetPassengers();
                }
            }
            catch (Exception ex)
            {
                throw ex;
            }

            return dt;
        }

        public DataTable GetPassengersByStatus(char status, string flightNo)
        {
            DataTable dt = new DataTable();
            try
            {
                using (BL bLayer = new BL())
                {
                    dt = bLayer.GetPassengersByStatus(status, flightNo);
                }
            }
            catch (Exception ex)
            {

                throw ex;
            }

            return dt;
        }

        public DataTable GetDailyReport(DateTime date)
        {
            DataTable dt = new DataTable();

            try
            {
                using (BL bLayer = new BL())
                {
                    dt = bLayer.GetDailyReport(date);
                }
            }
            catch (Exception ex)
            {

                throw ex;
            }

            return dt;
        }

        public decimal CalculateRefund(int pnr)
        {
            decimal refund = 0;

            try
            {
                using (BL bLayer = new BL())
                {
                    refund = bLayer.CalculateRefund(pnr);
                }

            }
            catch (Exception ex)
            {

                throw ex;
            }
            return refund;
        }

        public bool CancelPassenger(int pnr, decimal refund)
        {
            try
            {
                using (BL bLayer = new BL())
                {
                    return bLayer.CancelPassenger(pnr, refund);
                }

            }
            catch (Exception ex)
            {

                throw ex;
            }
        }

        public bool AddWaitList(int pnr, string flightNo, string fName, string lName, int age, char gender, char seatClass, string seatPref, string mealPref, string ssr)
        {
            try
            {
                using (BL bLayer = new BL())
                {
                    return bLayer.AddWaitList(pnr, flightNo, fName, lName, age, gender, seatClass, seatPref, mealPref, ssr);
                }

            }
            catch (Exception ex)
            {

                throw ex;
            }
        }
    }
}